#!/bin/bash 
set -e

TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage3}
SRC=${SRC:-/sources}

name=man-db
version=2.9.4

rm -rf $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name-$version.tar.xz -C $TMP

{ time \
   {

    cd $TMP/$name-$version
    
	sed -i '/find/s@/usr@@' init/systemd/man-db.service.in

	./configure --prefix=/usr                            \
	            --docdir=/usr/share/doc/$name-$version \
	            --sysconfdir=/etc                        \
	            --disable-setuid                         \
	            --enable-cache-owner=bin                 \
	            --with-browser=/usr/bin/lynx             \
	            --with-vgrind=/usr/bin/vgrind            \
	            --with-grap=/usr/bin/grap
    
    make
    
    make install

    }
} 2>&1 | tee $name.log
    
[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
